package com.rgbgame.physics;

import org.jbox2d.collision.Shape;
import org.jbox2d.dynamics.DestructionListener;
import org.jbox2d.dynamics.joints.Joint;

/**
 * This is called when a joint in the world is implicitly destroyed
 *	because an attached body is destroyed. This gives us a chance to
 *	nullify the mouse joint.
 */
class ConcreteDestructionListener implements DestructionListener {
	private PhysicsHandler physicsHandler;

	ConcreteDestructionListener(PhysicsHandler physicsHandler) {
		this.physicsHandler = physicsHandler;
	}
	public void sayGoodbye(Shape shape) {; }
	public void sayGoodbye(Joint joint) {
		if (this.physicsHandler.m_mouseJoint == joint) {
			this.physicsHandler.m_mouseJoint = null;
		} else {
			this.physicsHandler.jointDestroyed(joint);
		}
	}
}